/* USER CODE BEGIN Header */
/**
  ******************************************************************************
  * @file    usart.h
  * @brief   This file contains all the function prototypes for
  *          the usart.c file
  ******************************************************************************
  * @attention
  *
  * Copyright (c) 2023 STMicroelectronics.
  * All rights reserved.
  *
  * This software is licensed under terms that can be found in the LICENSE file
  * in the root directory of this software component.
  * If no LICENSE file comes with this software, it is provided AS-IS.
  *
  ******************************************************************************
  */
/* USER CODE END Header */
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __USART_H__
#define __USART_H__

#ifdef __cplusplus
extern "C" {
#endif

/* Includes ------------------------------------------------------------------*/
#include "oc_rsrc_cfg.h"

/* USER CODE BEGIN Includes */

/* USER CODE END Includes */

extern UART_HandleTypeDef huart4;

/* USER CODE BEGIN Private defines */

/* USER CODE END Private defines */

void MX_UART4_Init(void);

/* USER CODE BEGIN Prototypes */

/* uart 硬件配置 */
typedef struct uart_op_for_mboot_str
{
    int (*set_rxbuf_attr)(hw_buf_attr * buf_attr);  /* 设置接收缓冲区信息 */
    int (*set_txbuf_attr)(hw_buf_attr * buf_attr);  /* 设置发送缓冲区信息 */
    void (*start_recv)(void);                       /* 开始接收数据 */
    HW_STATUS (*check_is_rxed)(void);               /* 检测是否收到数据 */
    HW_STATUS (*check_is_txed)(void);               /* 检测是否发送完数据 */
    hw_buf_attr *(*get_txbuf)(void);                /* 获得 txbuf 缓冲区地址 */
    hw_buf_attr *(*get_data)(void);                 /* 获得 rxbuf 的数据 */
    void (*put_data)(hw_buf_attr * buf_attr);       /* 往串口写入数据 */
} uart_op_for_mboot;

/* 注册操作函数接口 */
uart_op_for_mboot *uart_op_for_mboot_register(void);

/* USER CODE END Prototypes */

#ifdef __cplusplus
}
#endif

#endif /* __USART_H__ */
